#Boa:Dialog:Dialog1

import wx
import ruleManager

def create(parent):
    return Dialog1(parent)

[wxID_DIALOG1, wxID_DIALOG1ADDBTN, wxID_DIALOG1AMOUNTTXT, wxID_DIALOG1BUTTON1, 
 wxID_DIALOG1COMBOBOX1, wxID_DIALOG1LISTBOX1, wxID_DIALOG1STATICTEXT1, 
] = [wx.NewId() for _init_ctrls in range(7)]

class Dialog1(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_DIALOG1, name='', parent=prnt,
              pos=wx.Point(283, 221), size=wx.Size(278, 308),
              style=wx.DEFAULT_DIALOG_STYLE, title='')
        self.SetClientSize(wx.Size(262, 270))

        self.comboBox1 = wx.ComboBox(choices=[], id=wxID_DIALOG1COMBOBOX1,
              name='comboBox1', parent=self, pos=wx.Point(24, 56),
              size=wx.Size(130, 21), style=wx.CB_READONLY, value='comboBox1')

        self.addBtn = wx.Button(id=wxID_DIALOG1ADDBTN, label='Add',
              name='addBtn', parent=self, pos=wx.Point(168, 56),
              size=wx.Size(75, 23), style=0)
        self.addBtn.Bind(wx.EVT_BUTTON, self.OnAddButton, id=wxID_DIALOG1ADDBTN)

        self.listBox1 = wx.ListBox(choices=[], id=wxID_DIALOG1LISTBOX1,
              name='listBox1', parent=self, pos=wx.Point(24, 88),
              size=wx.Size(216, 144), style=0)

        self.button1 = wx.Button(id=wxID_DIALOG1BUTTON1, label='Aceptar',
              name='button1', parent=self, pos=wx.Point(168, 240),
              size=wx.Size(75, 23), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnSaveButton,
              id=wxID_DIALOG1BUTTON1)

        self.staticText1 = wx.StaticText(id=wxID_DIALOG1STATICTEXT1,
              label='Cantidad (>=):', name='staticText1', parent=self,
              pos=wx.Point(24, 24), size=wx.Size(75, 13), style=0)

        self.amountTxt = wx.TextCtrl(id=wxID_DIALOG1AMOUNTTXT, name='amountTxt',
              parent=self, pos=wx.Point(136, 24), size=wx.Size(108, 21),
              style=0, value='1')

    def __init__(self, parent, type, elements):
        self._init_ctrls(parent)
        self.type = type
        self.comboBox1.Clear()
        self.comboBox1.AppendItems(elements)
        self.comboBox1.Select(0)        
        
    def OnAddButton(self, event):
        elem = self.comboBox1.GetValue()        
        if not elem in self.listBox1.Items:
            self.listBox1.Append(elem)
            
    def OnSaveButton(self, event):
        self.rule_spec = ruleManager.new_rule_spec(0, 0, self.listBox1.Items, self.amountTxt.GetValue(), 0, 0, self.type)
        self.Close()
